import { Component } from '@angular/core';
import { select, Store } from '@ngrx/store';
import { PrimeNGConfig } from 'primeng/api';
import { AppState } from './store/app.model';
import { UserState } from './store/user/user.model';
import { getToken } from './store/user/user.reducer';
import { UtilsService } from './service/utils.service';
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    providers:[],
})
export class AppComponent {
    menuMode = 'static';
    public token = undefined
    constructor(private primengConfig: PrimeNGConfig,public store: Store<AppState>,public utilsService:UtilsService) {
        
    }
    onUser(){
        //this.store.dispatch(setUser({user:this.userdata}))
        this.store.pipe(select(getToken)).subscribe((data)=>{
            console.log(data)
            if(data==undefined)this.token=undefined
            else this.token = data
        })
        if(this.token){
            this.utilsService.init()
        }
        //console.log(this.user.user.user? this.user.user.user:undefined)
    }
    ngOnInit() {
        this.onUser()
        this.primengConfig.ripple = true;
        document.documentElement.style.fontSize = '14px';
    }
    
}
